package io.renren.modules.project.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import io.renren.common.utils.RandomId;
import io.renren.modules.project.dao.ApplicantInfoDao;
import io.renren.modules.project.entity.ApplicantInfoEntity;
import io.renren.modules.project.service.ApplicantInfoService;



@Service("applicantInfoService")
public class ApplicantInfoServiceImpl implements ApplicantInfoService {
	@Autowired
	private ApplicantInfoDao applicantInfoDao;
	
	@Override
	public ApplicantInfoEntity queryObject(String id){
		return applicantInfoDao.queryObject(id);
	}
	
	@Override
	public List<ApplicantInfoEntity> queryList(Map<String, Object> map){
		return applicantInfoDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return applicantInfoDao.queryTotal(map);
	}
	
	@Override
	public boolean save(ApplicantInfoEntity applicantInfo){
		applicantInfo.setId(RandomId.createId()+"");
		List<String> applicantNameList = applicantInfoDao.queryArr();
		if (!applicantNameList.contains(applicantInfo.getApplicantName())){
			applicantInfoDao.save(applicantInfo);
			return true;
		}
		return false;
	}
	
	@Override
	public boolean update(ApplicantInfoEntity applicantInfo){
		List<String> applicantNameList = applicantInfoDao.queryArr();
		if (!applicantNameList.contains(applicantInfo.getApplicantName())){
			applicantInfoDao.update(applicantInfo);
			return true;
		}
		return false;
	}
	
	@Override
	public void delete(String id){
		applicantInfoDao.delete(id);
	}
	
	@Override
	public void deleteBatch(String[] ids){
		applicantInfoDao.deleteBatch(ids);
	}
	
}
